package mo.leetcode_top;

import java.util.HashSet;
import java.util.Set;

public class L217 {

    public boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>(nums.length);
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])) {
                return true;
            } else {
                set.add(nums[i]);
            }
        }
        return false;
    }

    public static void main(String[] args) {
        L217 test = new L217();
        System.out.println(test.containsDuplicate(new int[]{1, 2, 3, 4}));
    }
}
